package com.zdsoft.crm.controller;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class DbBakJobController {

	@GetMapping("/dbJob")
	public final String job(){
		StringBuffer sb = new StringBuffer();
		sb.append("cmd /c ") ; // 加这行试试
	    sb.append("C:\\Users\\mysqldump");
	    sb.append(" -uroot ");
	    sb.append(" -proot ");
	    sb.append(" -d ");
	    sb.append(" crm ");
	    sb.append(" sys_user ");
	    sb.append(">C:\\Users\\Administrator\\Desktop\\daochu1.txt");
	    String javaExecute = sb.toString();// 在CMD中执行的字符串
	    try {
	        Process p = Runtime.getRuntime().exec(javaExecute);
	        System.out.println("数据已导出到文件"+p);
	    } catch (IOException e) {
	        e.printStackTrace();
	    }
		return "redirect:/product/list";  
	}

}
